#include<iostream>
#include<vector>
#include<queue>

using namespace std;
const int maxn = 101;
int main(void)
{
    int N,M;
    cin >> N >> M;
    vector<int> nodes[maxn];
    for(int i = 0; i < M; i++) {
        int id,k;
        cin>>id>>k;
        for(int j = 0; j < k; j++) {
            int child;
            cin>>child;
            nodes[id].push_back(child);
        }
    }
    queue<vector<int> > qu_lev;
    vector<int> root;
    root.push_back(1);
    qu_lev.push(root);
    bool isRoot = true;

    while(!qu_lev.empty()) {
        vector<int> tempLev = qu_lev.front();
        qu_lev.pop();
        int leafNum = 0;
        vector<int> newLev;
        for(int i = 0; i < tempLev.size(); i++) {
            if(nodes[tempLev[i]].size()==0) leafNum++;
            else {
                for(int j = 0; j < nodes[tempLev[i]].size(); j++) {
                    newLev.push_back(nodes[tempLev[i]][j]);
                }
            }
        }
        if(isRoot) {
            printf("%d",leafNum);
            isRoot = false;
        }
        else {
            printf(" %d",leafNum);
        }
        if(newLev.size()!=0) qu_lev.push(newLev);
    }

    return 0;
}

/*
test data:
9 4
01 3 2 3 4
03 2 5 6
04 1 7
05 2 8 9
*/